package springapp.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import springapp.entity.SalaryEntity;
import springapp.service.SalaryService;
import springapp.util.Utils;

import com.google.gson.Gson;

@Controller
public class SalaryController implements IControllerConstants {

	@Autowired(required = true)
	private SalaryService salaryService;

	@RequestMapping(value="/getSalaryJson.htm", method = RequestMethod.GET)
	public @ResponseBody String handleRequest(
			@RequestParam("companyId") String companyId) throws Exception {
		SalaryEntity[] salaries = this.salaryService
				.getSalaryForCompanyId(Utils.getInt(companyId));
		Gson gson = new Gson();
		String json = gson.toJson(salaries);
		return json;
				
	}

}
